﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ProjTemp.Desktop.Common.Container;
using ProjTemp.Desktop.Common.View;
using System.ComponentModel.Composition;

namespace ProjTemp.Desktop.Common.MessageBox
{
    [Export(typeof(IMessageBox))]
    [PartCreationPolicy(CreationPolicy.NonShared)]
    public class MessageBoxService : IMessageBox
    {
        public MessageBoxResult Show(string text)
        {
            return Show(text, string.Empty, MessageBoxButton.OK, MessageBoxImage.None);
        }

        public MessageBoxResult Show(string text, string title)
        {
            return Show(text, title, MessageBoxButton.OK, MessageBoxImage.None);
        }

        public MessageBoxResult Show(string text, string title, MessageBoxButton button)
        {
            return Show(text, title, button, MessageBoxImage.None);
        }

        public MessageBoxResult Show(string text, string title, MessageBoxButton button, MessageBoxImage image)
        {
            IContainer container = new WindowWrapper();
            container.Title = title;
            var messageBox = new MessageBox();
            messageBox.Text = text;
            messageBox.ButtonType = button;
            messageBox.ImageType = image;

            container.Content = messageBox;
            messageBox.Container = container;
            container.Show(new ContainerSetting() { ResizeMode = System.Windows.ResizeMode.NoResize });

            return container.ReturnValue is MessageBoxResult ? ((MessageBoxResult)container.ReturnValue) : MessageBoxResult.None;
        }
    }
}
